package DesignPattern;

public class AbstractFactory {
    public static void main(String[] args) {
        new FactoryType().getFactory("Shape").getShape("Circle").draw();
    }
}

interface Color {
    void fill();
}

class Green implements Color {
    @Override
    public void fill() {
        System.out.println("Green");
    }
}

class Grey implements Color {
    @Override
    public void fill() {
        System.out.println("Grey");
    }
}

abstract class FactoryCollection {
    public abstract Shape getShape(String shapeName);

    public abstract Color getColor(String colorName);
}

class FactoryColor extends FactoryCollection {

    @Override
    public Shape getShape(String shapeName) {
        return null;
    }

    @Override
    public Color getColor(String colorName) {
        if (colorName.equalsIgnoreCase("Circle")) {
            return new Grey();
        } else {
            return new Green();
        }
    }
}

class FactoryShape extends FactoryCollection {

    @Override
    public Shape getShape(String shapeName) {
        if (shapeName.equalsIgnoreCase("Circle")) {
            return new Circle();
        } else {
            return new Square();
        }
    }

    @Override
    public Color getColor(String colorName) {
        return null;
    }
}

class FactoryType {
    public FactoryCollection getFactory(String factoryName) {
        if (factoryName.equalsIgnoreCase("Shape")) {
            return new FactoryShape();
        } else {
            return new FactoryColor();
        }
    }
}


